<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ApiPost
 *
 * @author dxx
 */

namespace app\common\traits;

use app\common\common\Helper;

trait ApiPost {

    public function _postArr($url, $str, $type = 'json', $timeOut = 10) {
        $helper = new Helper();
        try {
            return $helper->HttpPostJson($url, $str, $type, $timeOut);
        } catch (\Exception $ex) {
            throw new \Exception($ex->getMessage());
        }
    }

    public function outPutError($params) {
        $inPut = file_get_contents("php://input");
        return Helper::outPutError($params, $inPut, $this->_apiUserInfo);
    }

    public function output($params = [], $msg = 'success', $code = '200') {
        $inPut = file_get_contents("php://input");
        return Helper::output($params, $msg, $code, $inPut, $this->_apiUserInfo);
    }

}
